home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / A-B / 007.FracApp.cpt / MFracApp.p < prev    next >
Text File  |  1988-08-01  |  5KB  |  129 lines

  1. {------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MacApp Color QuickDraw Fractal Sample Application
  6. #
  7. #    FracApp
  8. #
  9. #    MFracApp.p    -    Pascal Source
  10. #
  11. #    Copyright © 1988 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                    8/88
  15. #
  16. #    Components:    MFracApp.p            August 1, 1988
  17. #                UFracApp.p            August 1, 1988
  18. #                UFracApp.inc1.p        August 1, 1988
  19. #                FracApp.r            August 1, 1988
  20. #                FracApp.make        August 1, 1988
  21. #
  22. #    This is a program to calculate the Mandelbrot set, allowing you to zoom in on areas
  23. #    that are selected with the mouse.  There are some special color tricks played
  24. #    in order to make the program more jazzy.  A special color table is used to give
  25. #    smooth transitions from one color to the next.  Color table animation is also
  26. #    supported, for the wowem effect of flowing Mandelbrot images. 
  27. #    The program is written in MacApp 1.1, which explains why it has a real user
  28. #    interface.  Mandelbrot images take about 30 minutes to calculate.  It is
  29. #    Juggler aware so you can put the program in the background where it will
  30. #    continue to calculate, while you do something more important, like look at 
  31. #    the source code.  It also handles multiple documents, and reading/writing of
  32. #    PICT files using the bottlenecks to minimize the memory hit.
  33. #    
  34. #    This program is intended to be a real world example of handling color in a
  35. #    nontrivial fashion.  As such it has some rather special color requirements,
  36. #    and those don’t match the current system architecture very well.  The program
  37. #    is designed to be compatible with the future, it will not break in future
  38. #    systems.  However, it does not use the Palette Manager, which means that
  39. #    there will be situations where the colors will not look right in either FracApp
  40. #    or another program running under MultiFinder.  The approach that FracApp
  41. #    uses is thus not the preferred Apple approach and does NOT have the Apple
  42. #    seal of approval from engineering.  The only way to get the stamp of approval
  43. #    is to use the Palette Manager.  To do a program of this form, you cannot
  44. #    use the Palette Manager without some extra hacks that are compatibility
  45. #    risks in themselves.  So... use at your own risk.  If you are forced to revise your 
  46. #    program because you followed this as an example, you cannot gripe to Apple, since
  47. #    it is not fully approved.  You just have to change your program, which I hope is no
  48. #    big deal.  You can give this code to other people, as long as they recognize
  49. #    that it is not fully approved too. 
  50. #    
  51. #    Unless you have very special color requirements, you should use the Palette 
  52. #    Manager.  It works for most things, and is much easier to use than the
  53. #    approach taken here.  There are a few things it won’t do of course, leading
  54. #    to this code.  If you can do it, use the Palette Manager and save yourself
  55. #    some grief.
  56. #            Written in MacApp Object Pascal code.
  57. #            Compatibility rating = 2.  (nothing will break, but it may not
  58. #                always look correct.)
  59. #
  60. ------------------------------------------------------------------------------}
  61. {copyright 1988 by Bob.  All rights reserved.
  62.     February 1, 1988. 
  63.     Written by Bo3b Johnson of Developer Technical Support. }
  64.  
  65. PROGRAM FracApp;
  66.  
  67. USES
  68.     {$LOAD MacIntf.LOAD}
  69.         MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
  70.     {$LOAD UMacApp.LOAD}
  71.         UObject, UList, UMacApp,
  72.     {$LOAD UBobLips.LOAD}
  73.         PaletteMgr, UPrinting,
  74.     {$LOAD}
  75.  
  76.     UFracApp;
  77.  
  78.  
  79. VAR
  80.     {The application object:}
  81.     gFracAppApplication:   TFracAppApplication;
  82.     error:    Integer;
  83.     
  84.  
  85. FUNCTION ForceEnvirons(minimumSystemVersion: INTEGER;
  86.                               minimumProcessor: INTEGER; needsFPU: BOOLEAN;
  87.                               needsColorQD: BOOLEAN;
  88.                               minimumATDrvrVersNum: INTEGER): BOOLEAN;
  89.  
  90.     VAR
  91.         error: OSErr;
  92.         theWorld: SysEnvRec;
  93.  
  94.     BEGIN
  95.         error := SysEnvirons(1,theWorld);
  96.         WITH theWorld DO
  97.             ForceEnvirons := (systemVersion >= minimumSystemVersion) AND
  98.                                   (processor >= minimumProcessor) AND (hasFPU >=
  99.                                   needsFPU) AND (needsColorQD >= hasColorQD) AND
  100.                                   (atDrvrVersNum >= minimumATDrvrVersNum);
  101.     END;
  102.  
  103.  
  104. BEGIN
  105.     {Initialize the Toolbox, making 8 calls to MoreMasters:}
  106.     InitToolbox(8);
  107.  
  108.         { The first thing we have to do is ensure that we can run in this environment.  
  109.             We must do a ForceEnvirons to avoid crashing needlessly on machines where
  110.             we have no color or 881.  The minimum system is 4.2 since we need the more
  111.             robust Palette Manager.  We don’t use 020 code, but we require an FPU.  We
  112.             also require colorQD.  If we don’t have the stuff we need, we will alert and
  113.             leave.  }
  114.      IF NOT ForceEnvirons($0420, envDontCare, TRUE, TRUE, envDontCare) THEN
  115.         Failure (kWrongMachine, 0);
  116.     
  117.     {Initialize the UPrinting unit:}
  118.     InitPrinting;
  119.  
  120.     {Allocate a new TFracAppApplication object:}
  121.     New(gFracAppApplication);
  122.  
  123.     {Initialize that new object:}
  124.     gFracAppApplication.IFracAppApplication(kFileType);
  125.  
  126.     {Run the application.  When it's done, exit.}
  127.     gFracAppApplication.Run;
  128. END.
  129.